如何在JS vue中将返回值放入另一个返回值 您所在的位置:网站首页 vue :key 如何在JS vue中将返回值放入另一个返回值

如何在JS vue中将返回值放入另一个返回值

#如何在JS vue中将返回值放入另一个返回值| 来源: 网络整理| 查看: 265

我希望“topic1”成为我的品种名称和键的值,但是当我尝试用 this.topic1 替换手动输入时,它什么也没显示。

或者还有其他方法可以让我的按钮名称与我的检索 API 参数相同,并在我单击它时发送它的名称?

new Vue({

  el: '#app2',

  components: { Async },

  data() {

    return {

      topic1: null,

      topic2: null,

      currentBreed: 0,

      breeds: [

        { name: this.topic1 , key: this.topic1 },

        { name: "German Shepherd", key: "germanshepherd" },

        { name: "Husky", key: "husky" },

        { name: "Pug", key: "pug" },

        { name: "(Error)", key: "error" },

      ]

    }

  },

  async created() {

    try {

      this.promise = axios.get(

        "https://k67r3w45c4.execute-api.ap-southeast-1.amazonaws.com/TwitterTrends"

      );

      const res = await this.promise;

      this.topic1 = res.data[0].Trends;

      this.topic2 = res.data[1].Trends;  

    } catch (e) {

      console.error(e);

    }  

  },

  async mounted () {

  let test = this.topic1;

  },

  computed: {

    breedKey() {

      return this.breeds[this.currentBreed].key;

    }

  }

})



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有